# include "scene.h"

# include <stdio.h>
# include <stdlib.h>

/* This function accepts the temperature in Kelvin and returns density of water. */
extern double dens(double T)
  {
   FILE *ptr;

# ifdef RETURN_CONST_DENS
  T = T_INIT;
# endif

   T -= ABS_ZERO;

   if( (T < 0) || (T > 100) )
       {
        if((ptr = fopen("dens_log.txt", "w")) == (FILE*)0) ptr = stderr;

        fprintf(ptr, "ERROR:: In function 'dens()': \"T = %E Kelvin\"; However, it should be \"%E K <= T <= %E K\"\n",\
                      T+ABS_ZERO, 0+ABS_ZERO, 100+ABS_ZERO);

        if(ptr != stderr) fclose(ptr);
        exit(-1);
       }

   return 999.8815 + T*5.96E-2 - T*T*7.7824E-3 + T*T*T*4.3739E-5 - T*T*T*T*1.3742E-7;
  }

